//
//  logonViewController.m
//  豆瓣2
//
//  Created by dllo on 15/12/19.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "logonViewController.h"
#import "logonView.h"
@interface logonViewController ()<UITextFieldDelegate>

@property (nonatomic ,retain) logonView *myView;
@end

@implementation logonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor redColor];
    self.myView = [[logonView alloc]initWithFrame:self.view.bounds];
    self.myView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.myView];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(longButtonAction:)];
}

- (void)longButtonAction:(UIBarButtonItem *)bnt{
    
    if (self.myView.userfield.text.length <=0 || self.myView.surefield.text.length <=0||self.myView.contactfield.text<=0) {
        
        UIAlertController *aler = [UIAlertController alertControllerWithTitle:@"提示" message:@"账号或密码不能为空" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:aler animated:YES completion:^{
            
        }];
        
        UIAlertAction *a = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [aler addAction:a];

    }else{
        
        [[NSUserDefaults standardUserDefaults]setObject:self.myView.userfield.text forKey:@"name"];
        [[NSUserDefaults standardUserDefaults]setObject:self.myView.surefield.text forKey:@"pass"];
        [self dismissViewControllerAnimated:YES completion:^{
            
            
        }];
    }
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
